Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

386
Vistas
Simple API call with "Bearer" token Authorization using Ajax

My problem is that I couldn't fetch data from API using Ajax.

I'm using a JWT token for authentication and when I call the API from Postman, I get the data successfully.

enter image description here

However, when calling the API using ajax, an ERR_ABORTED 401 (Unauthorized) error is detected. Here's the code:

$.ajax({
    type: "GET",
    url: API_URL,
    dataType: 'jsonp',
    contentType: "application/json",
    headers: {
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + access_token,
    },
    data: {}, 
    success: function(resp){
        console.log(resp)
    }, 
    error: function(error){
    }    
})

Also, I get the same error when I copy and use the code snippet generated by POSTMAN.

enter image description here

I've searched a lot of answers for this and applied them, but it doesn't work for me.

Can someone help with this?

Thank you in advance.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda